<a href="?act=edit_category&add=1"><img src="images/add_new.gif">Thêm danh mục</img></a>
<table class="tb_table" width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="tb_head">
    <td>Tên danh mục</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
	<td>Vị trí</td>
    <td>&nbsp;</td>
    <td>Thao tác</td>
  </tr>
	<?php 
		load_category($categories, 0);
	?>
</table>
<a href="?act=edit_category&add=1"><img src="images/add_new.gif">Thêm danh mục</img></a>

<?
function load_category($categories, $index)
{

	$positions = array(
		"NULL" => "Không hiển thị",
		"TOP" => "Bên trên",
		"LEFT" => "Bên trái",
		"RIGHT TOP" => "Bên phải trên",
		"RIGHT BOTTOM" => "Bên phải dưới"
 	);

	$cnt = 0;
	foreach ($categories as $category) 
	{
		$cnt ++;
	?>
	<tr class="tb_content">
		<td style='text-align:left;'><div style='float:left;width:20px;'>&nbsp;</div><img src='/admin/images/node.gif' style="padding-left:<?=16*$index?>px" align="left" /><div style='float:left;padding:5px;'><?php echo $category->getname() ?></div></td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
        <td><?=$positions[$category->getdisplay_position()]?></td>
		<td><a href="?act=edit_category&add=1&parent=<?=$category->getid()?>">Thêm mục con</a></td>
		<td><a href="?act=edit_category&category_id=<?php echo $category->getid() ?>">Sửa</a></td>
	</tr>
	<?
		$category_children = Category::getAllCategories($category->getid());
		if ($category_children)
			load_category($category_children, $index+1);
	}
}
?>